<?php

/**
 * Person filter form base class.
 *
 * @package    makethetouch
 * @subpackage filter
 * @author     Sebastien Chassande-Barrioz
 * @version    SVN: $Id: sfDoctrineFormFilterGeneratedTemplate.php 29570 2010-05-21 14:49:47Z Kris.Wallsmith $
 */
abstract class BasePersonFormFilter extends BaseFormFilterDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'first_name'       => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'last_name'        => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'email'            => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'phone_mobile'     => new sfWidgetFormFilterInput(),
      'phone_2'          => new sfWidgetFormFilterInput(),
      'country'          => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Country'), 'add_empty' => true)),
      'referee_level'    => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('RefereeLevel'), 'add_empty' => true)),
      'address'          => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Address'), 'add_empty' => true)),
      'my_club'          => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Club'), 'add_empty' => true)),
      'password'         => new sfWidgetFormFilterInput(),
      'status'           => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'level'            => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'subscriptiondate' => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate())),
      'subscriptionip'   => new sfWidgetFormFilterInput(),
    ));

    $this->setValidators(array(
      'first_name'       => new sfValidatorPass(array('required' => false)),
      'last_name'        => new sfValidatorPass(array('required' => false)),
      'email'            => new sfValidatorPass(array('required' => false)),
      'phone_mobile'     => new sfValidatorPass(array('required' => false)),
      'phone_2'          => new sfValidatorPass(array('required' => false)),
      'country'          => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('Country'), 'column' => 'code')),
      'referee_level'    => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('RefereeLevel'), 'column' => 'color')),
      'address'          => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('Address'), 'column' => 'idaddress')),
      'my_club'          => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('Club'), 'column' => 'idclub')),
      'password'         => new sfValidatorPass(array('required' => false)),
      'status'           => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'level'            => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'subscriptiondate' => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 00:00:00')), 'to_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 23:59:59')))),
      'subscriptionip'   => new sfValidatorPass(array('required' => false)),
    ));

    $this->widgetSchema->setNameFormat('person_filters[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Person';
  }

  public function getFields()
  {
    return array(
      'login'            => 'Text',
      'first_name'       => 'Text',
      'last_name'        => 'Text',
      'email'            => 'Text',
      'phone_mobile'     => 'Text',
      'phone_2'          => 'Text',
      'country'          => 'ForeignKey',
      'referee_level'    => 'ForeignKey',
      'address'          => 'ForeignKey',
      'my_club'          => 'ForeignKey',
      'password'         => 'Text',
      'status'           => 'Number',
      'level'            => 'Number',
      'subscriptiondate' => 'Date',
      'subscriptionip'   => 'Text',
    );
  }
}
